home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / amiga / asrc29k.lha / sockcmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-08  |  1.5 KB  |  81 lines

  1. #include <stdio.h>
  2. #include "global.h"
  3. #include "mbuf.h"
  4. #include "proc.h"
  5. #include "usock.h"
  6. #include "socket.h"
  7. #include "ax25.h"
  8. #include "netrom.h"
  9. #include "tcp.h"
  10. #include "udp.h"
  11. #include "commands.h"
  12. #include "config.h"
  13.  
  14. /* Socket status display command */
  15. int
  16. dosock(argc,argv,p)
  17. int argc;
  18. char *argv[];
  19. void *p;
  20. {
  21.     register struct usock *up;
  22.     int s,i;
  23.     struct sockaddr fsock;
  24.     char *cp;
  25.  
  26.     if(argc < 2){
  27.         tprintf("S#  Type    PCB      Remote socket         Owner\n");
  28.         for(s=0;s<Nusock;s++){
  29.             up = &Usock[s];
  30.             if(up->type == NOTUSED)
  31.                 continue;
  32.             i = sizeof(fsock);
  33.             if(getpeername(s,(char *)&fsock,&i) == 0 && i != 0)
  34.                 cp = psocket(&fsock);
  35.             else
  36.                 cp = "";
  37.  
  38.             if(tprintf("%3d %-8s%-8lx %-22s%-8lx %-10s\n",
  39.              s,Socktypes[up->type],ptol(up->cb.p),cp,
  40.              ptol(up->owner),up->owner->name) == EOF)
  41.                 break;
  42.         }
  43.         return 0;
  44.     }
  45.     s = atoi(argv[1]);
  46.     if(s < 0 || s >= Nusock){
  47.         tprintf("Number out of range\n");
  48.         return 1;
  49.     }
  50.     up = &Usock[s];
  51.     tprintf("%s %lx\n",Socktypes[up->type],ptol(up->cb.p));
  52.     if(up->cb.p == NULL)
  53.         return 0;
  54.     switch(up->type){
  55.     case TYPE_LOCAL_DGRAM:
  56.         tprintf("Qlen: %u packets\n",socklen(s,0));
  57.         break;
  58.     case TYPE_LOCAL_STREAM:
  59.         tprintf("Qlen: %u bytes\n",socklen(s,0));
  60.         break;
  61.     case TYPE_TCP:
  62.         st_tcp(up->cb.tcb);
  63.         break;
  64.     case TYPE_UDP:
  65.         st_udp(up->cb.udp,0);
  66.         break;
  67. #ifdef    AX25
  68.     case TYPE_AX25I:
  69.         st_ax25(up->cb.ax25);
  70.         break;
  71. #endif
  72. #ifdef    NETROM
  73.     case TYPE_NETROML4:
  74.         donrdump(up->cb.nr4);
  75.         break;
  76. #endif
  77.     }
  78.     return 0;    
  79. }
  80.  
  81.